package cn.fl.riskctrl.tddb.service.impl;

import java.util.List;

import fl.riskctrl.facade.tddb.api.ITddbBatchApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.fl.riskctrl.tddb.service.ITdPolicyHitRulesService;
import cn.fl.riskctrl.tddb.service.ITdSearchService;
import cn.fl.riskctrl.tddb.transform.TdApplyVOTransform;
import cn.fl.riskctrl.tddb.transform.TdHitRulesVOTransform;
import cn.fl.riskctrl.tddb.transform.TdPolicyHitRulesVOTransform;
import cn.fl.riskctrl.tddb.transform.TdPolicyVOTransform;
import cn.fl.riskctrl.tddb.transform.TddcsnApplyLVOTransform;
import cn.fl.riskctrl.tddb.transform.TddcsnApplyVOTransform;
import cn.fl.riskctrl.tddb.transform.TddcsnReportVOTransform;
import cn.fl.riskctrl.tddb.transform.TdmpApplyLVOTransform;
import cn.fl.riskctrl.tddb.transform.TdmpApplyVOTransform;
import cn.fl.riskctrl.tddb.transform.TdmpReportVOTransform;
import cn.fl.riskctrl.tddb.vo.TdApplyVO;
import cn.fl.riskctrl.tddb.vo.TdHitRulesVO;
import cn.fl.riskctrl.tddb.vo.TdPolicyHitRulesVO;
import cn.fl.riskctrl.tddb.vo.TdPolicyVO;
import cn.fl.riskctrl.tddb.vo.TddcsnApplyLVO;
import cn.fl.riskctrl.tddb.vo.TddcsnApplyVO;
import cn.fl.riskctrl.tddb.vo.TddcsnReportVO;
import cn.fl.riskctrl.tddb.vo.TdmpApplyLVO;
import cn.fl.riskctrl.tddb.vo.TdmpApplyVO;
import cn.fl.riskctrl.tddb.vo.TdmpReportVO;
import fl.riskctrl.facade.tddb.api.ITddbSearchApiService;
import fl.riskctrl.facade.tddb.dto.TdApplyDTO;
import fl.riskctrl.facade.tddb.dto.TdHitRulesDTO;
import fl.riskctrl.facade.tddb.dto.TdPolicyDTO;
import fl.riskctrl.facade.tddb.dto.TdPolicyHitRulesDTO;
import fl.riskctrl.facade.tddb.dto.TddcsnApplyDTO;
import fl.riskctrl.facade.tddb.dto.TddcsnApplyLDTO;
import fl.riskctrl.facade.tddb.dto.TddcsnReportDTO;
import fl.riskctrl.facade.tddb.dto.TdmpApplyDTO;
import fl.riskctrl.facade.tddb.dto.TdmpApplyLDTO;
import fl.riskctrl.facade.tddb.dto.TdmpReportDTO;

/**
 * @Description: 同盾策略集命中规则

 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
@SuppressWarnings("unchecked")
public class TdSearchServiceImpl implements ITdSearchService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(ITdPolicyHitRulesService.class);
	@Autowired
	private ITddbSearchApiService tddbSearchService;

    @Autowired
    private ITddbBatchApiService tddbBatchApiService;

	@Override
	public Pager searchTdApplyPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdApplyPage(page);
		List<TdApplyDTO> list = (List<TdApplyDTO>)pager.getResultList();
		List<TdApplyVO> voList = TdApplyVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTddcsnApplyPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTddcsnApplyPage(page);
		List<TddcsnApplyDTO> list = (List<TddcsnApplyDTO>)pager.getResultList();
		List<TddcsnApplyVO> voList = TddcsnApplyVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTddcsnApplyLPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTddcsnApplyLPage(page);
		List<TddcsnApplyLDTO> list = (List<TddcsnApplyLDTO>)pager.getResultList();
		List<TddcsnApplyLVO> voList = TddcsnApplyLVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTddcsnReportPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTddcsnReportPage(page);
		List<TddcsnReportDTO> list = (List<TddcsnReportDTO>)pager.getResultList();
		List<TddcsnReportVO> voList = TddcsnReportVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdmpApplyPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdmpApplyPage(page);
		List<TdmpApplyDTO> list = (List<TdmpApplyDTO>)pager.getResultList();
		List<TdmpApplyVO> voList = TdmpApplyVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdmpApplyLPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdmpApplyLPage(page);
		List<TdmpApplyLDTO> list = (List<TdmpApplyLDTO>)pager.getResultList();
		List<TdmpApplyLVO> voList = TdmpApplyLVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdmpReportPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdmpReportPage(page);
		List<TdmpReportDTO> list = (List<TdmpReportDTO>)pager.getResultList();
		List<TdmpReportVO> voList = TdmpReportVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdPolicyPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdPolicyPage(page);
		List<TdPolicyDTO> list = (List<TdPolicyDTO>)pager.getResultList();
		List<TdPolicyVO> voList = TdPolicyVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdPolicyHitRulesPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdPolicyHitRulesPage(page);
		List<TdPolicyHitRulesDTO> list = (List<TdPolicyHitRulesDTO>)pager.getResultList();
		List<TdPolicyHitRulesVO> voList = TdPolicyHitRulesVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

	@Override
	public Pager searchTdHitRulesPage(Pager page) throws BaseException {
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.tddbSearchService.searchTdHitRulesPage(page);
		List<TdHitRulesDTO> list = (List<TdHitRulesDTO>)pager.getResultList();
		List<TdHitRulesVO> voList = TdHitRulesVOTransform.toVOList(list);
		pager.setResultList(voList);
		return pager;
	}

    @Override
    public boolean noTransRskCtrlRecConvertTdApply() throws BaseException {
        //异步处理
        this.tddbBatchApiService.noTransRskCtrlRecConvertTdApply();
        return true;
    }

    @Override
    public boolean noTransTddcsnDistributeData(List<Long> idList) throws BaseException {
        //异步处理
        this.tddbBatchApiService.noTransTddcsnDistributeData(idList);
        return true;
    }

    @Override
    public boolean noTransTdmpDistributeData(List<Long> idList) throws BaseException {
        //异步处理
        this.tddbBatchApiService.noTransTdmpDistributeData(idList);
        return true;
    }
	
	
}
